{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f04dd603-a2d1-48ce-8c17-9f1dba8de1ee",
   "metadata": {},
   "source": [
    "Chapter 01\n",
    "\n",
    "# 可视化标量乘法\n",
    "《线性代数》 | 鸢尾花书：数学不难"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ccafb456-2453-4c82-8a65-b1963a370cb2",
   "metadata": {},
   "source": [
    "这段代码的核心目标是展示**向量的标量乘法**及其**几何变换**。它定义了一个二维向量，并将其与标量相乘，然后使用 `matplotlib.pyplot.arrow()` 在二维坐标系中绘制原始向量及其缩放后的向量，以观察几何上的变化。\n",
    "\n",
    "首先，代码使用 NumPy 定义一个二维向量 $ \\mathbf{a} $：\n",
    "$$\n",
    "\\mathbf{a} = \\begin{bmatrix} 2 \\\\ 1 \\end{bmatrix}\n",
    "$$\n",
    "这个向量表示从原点 $(0,0)$ 指向点 $(2,1)$，它的长度（欧几里得范数）可以计算为：\n",
    "$$\n",
    "\\|\\mathbf{a}\\| = \\sqrt{2^2 + 1^2} = \\sqrt{5}\n",
    "$$\n",
    "\n",
    "接下来，代码定义了一个标量 $ k = -2 $ 并对向量 $\\mathbf{a}$ 进行标量乘法：\n",
    "$$\n",
    "k \\mathbf{a} = (-2) \\cdot \\begin{bmatrix} 2 \\\\ 1 \\end{bmatrix} =\n",
    "\\begin{bmatrix} -4 \\\\ -2 \\end{bmatrix}\n",
    "$$\n",
    "这个操作的几何意义是：\n",
    "- 由于 $ |k| = 2 $，新向量的长度是原向量的 $ 2 $ 倍，即：\n",
    "  $$\n",
    "  \\| k\\mathbf{a} \\| = |k| \\cdot \\|\\mathbf{a}\\| = 2 \\sqrt{5}\n",
    "  $$\n",
    "- 由于 $ k $ 是负数，向量的方向**翻转**，即 $ k \\mathbf{a} $ 指向与 $ \\mathbf{a} $ 相反的方向。\n",
    "\n",
    "随后，代码使用 Matplotlib 可视化这两个向量：\n",
    "- `plt.arrow(0, 0, a_vec[0], a_vec[1], ...)` 绘制原始向量 $\\mathbf{a}$，颜色为蓝色（`#00B0F0`）。\n",
    "- `plt.arrow(0, 0, k_a_vec[0], k_a_vec[1], ...)` 绘制经过标量乘法变换后的向量 $ k\\mathbf{a} $，颜色为绿色（`#92D050`）。\n",
    "- 由于 `plt.arrow()` 仅绘制箭头，代码通过 `head_width=0.2, head_length=0.3` 调整箭头的形状，使其在图像中更清晰可见。\n",
    "\n",
    "代码最后通过 `plt.xlim(-5,5)` 和 `plt.ylim(-5,5)` 设置坐标轴范围，并添加网格线，使向量在坐标系中的位置更加直观。由于 `plt.legend()` 不能直接与 `plt.arrow()` 结合使用，因此需要额外的 `plt.text()` 来标注向量。\n",
    "\n",
    "### **几何解释**\n",
    "从几何角度来看，标量乘法执行的是**伸缩变换**（scaling transformation）：\n",
    "- 当 $ k > 1 $ 时，向量的长度增加，方向保持不变。\n",
    "- 当 $ 0 < k < 1 $ 时，向量的长度缩短，方向保持不变。\n",
    "- 当 $ k < 0 $ 时，向量不仅**翻转方向**，还会被缩放。\n",
    "\n",
    "在本例中，原向量 $\\mathbf{a}$ 指向第一象限，而变换后的向量 $ k\\mathbf{a} $ 指向与之**完全相反的第三象限**，但长度变为原来的两倍。这说明**负数标量会导致向量方向翻转，但不会影响共线性**，即 $ \\mathbf{a} $ 和 $ k\\mathbf{a} $ 始终位于同一条直线上。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4c90e233-0106-40e6-afdb-c6daa294d74b",
   "metadata": {},
   "source": [
    "## 初始化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ddcc3d0f-f93c-4b86-9d14-efe61bc9a360",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9cbeb7b4-a95c-4b24-a041-4b739e3b3ce3",
   "metadata": {},
   "source": [
    "## 定义向量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e57bf3a3-f3de-4954-a808-1b099f3ce715",
   "metadata": {},
   "outputs": [],
   "source": [
    "a_vec = np.array([2, 1])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5e67c60f-7118-4947-9dee-ba9312d18a77",
   "metadata": {},
   "source": [
    "## 标量乘法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "167b611d-3fa9-459c-913a-ed4e175488bf",
   "metadata": {},
   "outputs": [],
   "source": [
    "k = -2\n",
    "k_a_vec = k * a_vec"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7b607503-7ee3-4c77-946d-4b2fe9d1bdf5",
   "metadata": {},
   "source": [
    "## 可视化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "119ddbbe-2f3e-45c7-bf6d-383283e07f00",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x2453a99ce60>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgQAAAH/CAYAAAAov8XRAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAtH0lEQVR4nO3df3RU9Z3/8dfk1ySBJDAEkJTJDwOCBZFKLIbClihSsaXirrZYDwst5XypQMWsVaL9Cri4aXe11eqKoC7YHluwZYH+gi9Y+aGLKQHEWlQUBAOEX3FgJgSYZJL7/cPNSMwPMpPce+cmz8c5c+RO7sznzchhnty5M+MyDMMQAADo1uLsHgAAANiPIAAAAAQBAAAgCAAAgAgCAAAgggAAAIggAAAAIggAAIAIAgAAIIIAAADI5CBYtGiRXC5Xk8sVV1xh5pIAACAKCWYvMGzYML366qvh7fj4eLOXBAAAETI9CBISEjgqAABAjDM9CD788ENlZWXJ7XZr9OjR+rd/+zddeeWVLe4bDAYVDAbD2w0NDfL5fOrTp49cLpfZowIA4GiGYai6ulpZWVmKi4vsrACXmV9/vGHDBp0/f15XXXWVTp48qSVLluj999/Xvn371KdPn2b7L1q0SIsXLzZrHAAAuoUjR45o4MCBEd3G1CD4vJqaGuXn5+uBBx5QcXFxs59//giB3+9Xdna2jhw5ovT0dKvG7DCfzydJ8ng8Nk8SOafOztzW8vl8mjVrltasWWP3KBFx6uMtOXd25rbWxx9/rBEjRujs2bPKyMiI6Lamv2RwqR49euiaa67Rhx9+2OLP3W633G53s+vT09MdFQShUEiSHDVzI6fOztzWCoVCSkhIcOTckvMeb8m5szO3tdLS0iQpqpfZLf0cgmAwqPfee08DBgywclkAAHAZpgbB/fffr23btunQoUP661//qjvuuEOBQEDTp083c1kAABAhU18yOHr0qO666y5VVVWpb9++uuGGG1RWVqacnBwzlwUAABEyNQhWrVpl5t0DALqohoYG1dbW2rZ+49oXL160bYaWJCYmmvYBf5aeVAgAwOXU1tbq0KFDamhosG2GxrXPnDlj2wyt6dWrl6644opO/3weggAAEDMMw9Dx48cVHx8vr9cb8YfrdJbGdxkkJMTO06RhGDp//rxOnTolSZ1+gn7s/E4BAN1eKBTS+fPnlZWVpdTUVFvnkGIrCCQpJSVFknTq1Cn169evU18+4OuPAQAxo76+XpKUlJRk8ySxqzGU6urqOvV+CQIAQMzh+2taZ9ZjQxAAAADOIQAAxL6K8w2qqrXsq3fUK75B2Snd69/MBAEAIKZVnG/QkL9U66KF70JMjpP2jU/RlWnWrWm37pU/AADHqao1LI0BSbrYIEuPSMQCggAAgE6wceNGjR07Vr169VKfPn30jW98QwcPHrR7rHYjCAAA6AQ1NTUqLi5WeXm5/vKXvyguLk633367rZ+4GAnOIQAAoBP80z/9U5PtF198Uf369dO7776r4cOH2zRV+3GEAACATnDw4EF95zvf0ZVXXqn09HTl5eVJkioqKmyerH04QgAAQCeYPHmyvF6vnn/+eWVlZamhoUHDhw+39VsbI0EQAADQQZ988onee+89LVu2TOPGjZMkvfHGGzZPFRmCAACADurdu7f69Omj5cuXa8CAAaqoqNCCBQvsHisinEMAAEAHxcXFadWqVdq9e7eGDx+u++67T//xH/9h91gR4QgBACCmZSa5lBwnyz+pMDMpsi8RmjBhgt59990m1xmGcz7ciCAAAMS07NQ47b8pzeLvMqjnuwwAAIg12alxyk61br1QyDn/su8s3St/AABAiwgCAABAEAAAAIIAAACIIAAAACIIAACACAIAACA+hwAA4ADVtad1IRSwbL1EpSotqW+79x8/frxGjhypJ5980ryhTEYQAABiWnXtaf3q/TmqN+osWzPelai7Bj2l3gkDOu0+x48fr61bt3ba/XU2XjIAAMS0C6GApTEgSfVGnS7WV3f4fj744AOtWrWqyXV79uzRH/7whw7fd2cjCAAA6GQbN25URkaGysrKtGXLFn3rW9/S2bNntXDhQj388MMaPHiwJKm8vFw333yzMjMzlZGRoa9+9avas2ePLTMTBAAAdKJVq1bpW9/6ln75y1/qn//5n7Vs2TJNmDBBb7/9tg4cOKANGzZo6NChkqTq6mpNnz5dr7/+usrKyjR48GDdeuutqq7u+NGJSHEOAQAAneTZZ5/VQw89pPXr16uoqEhnzpzRww8/rKqqKl177bXKz8/XpEmT9OSTT2rIkCG68cYbm9x+2bJl6t27t7Zt26ZvfOMbls5OEAAA0AnWrFmjkydP6o033tCXv/xlSdKpU6c0btw43XXXXRo/frweffRR7dmzRx988IGGDBmiU6dO6ZFHHtFrr72mkydPqr6+XufPn1dFRYXl8xMEAAB0gpEjR2rPnj1asWKFrr/+erlcLg0ZMkRDhgxpst91112n6667TpI0Y8YMnT59Wk8++aRycnLkdrtVWFio2tpay+e37ByC0tJSuVwuzZ8/36olAQCwTH5+vrZs2aL169dr3rx5zX7e0lsOX3/9df3whz/UrbfeqmHDhsntdquqqsqCaZuz5AhBeXm5li9frhEjRlixHAAAtrjqqqu0ZcsWjR8/XgkJCZf9oKJBgwbpV7/6lQoKChQIBPSjH/1IKSkp1gz7OaYfITh37pzuvvtuPf/88+rdu7fZywEAYKshQ4botdde029+8xv9y7/8S5v7/td//ZfOnDmj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TuHHj2n0bR5xD4OSvUv78fD179pQk5efna+DAgXaM1C47d+7Uzp07NXbsWPXu3VsfffSRHnnkEeXn58f0iUGVlZUaP368srOz9fjjj+v06dPhn0X6nlyrVVRUyOfzqaKiQvX19eHPqhg0aFD4z00sKC4u1rRp01RQUKDCwkItX75cFRUVmj17tt2jtencuXM6cOBAePvQoUPau3evPB5PzP49MmfOHP3617/W+vXrlZaWFj5PIyMjQykpKTZP17qHHnpIkyZNktfrVXV1tVatWqWtW7dq48aNdo/WprS0tGbnZ/To0UN9+vSJ+fM27r//fk2ePFnZ2dk6deqUlixZokAgoOnTp7f/Tsx59aJz7d692xg9erSRkZFhJCcnG0OGDDEWLlxo1NTU2D1axOw+h6C9/va3vxlFRUWGx+Mx3G63kZuba8yePds4evSo3aO1acWKFa2+Vh/rpk+f3uLcW7ZssXu0Zv7zP//TyMnJMZKSkozrrrvOEW+D27JlS4uP7/Tp0+0erVWt/VlesWKF3aO16Xvf+174z0ffvn2Nm266ydi0aZPdY0XFKecQfPvb3zYGDBhgJCYmGllZWcY//uM/RnzOBl9/DAAAnPVJhQAAwBwEAQAAIAgAAABBAAAARBAAAAARBAAAQAQBAAAQQQAAAEQQAAAAEQQAAEAEAQAAEEEAAAAk/X++dBfNbsDS/AAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 600x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(6,6))\n",
    "\n",
    "# 绘制向量 a\n",
    "plt.arrow(0, 0, a_vec[0], a_vec[1], \n",
    "          head_width=0.2, head_length=0.3, \n",
    "          fc='#00B0F0', ec='#00B0F0', label=\"a\")\n",
    "\n",
    "# 绘制向量 k * a\n",
    "plt.arrow(0, 0, k_a_vec[0], k_a_vec[1], \n",
    "          head_width=0.2, head_length=0.3, \n",
    "          fc='#92D050', ec='#92D050', label=\"k*a\")\n",
    "\n",
    "# 装饰\n",
    "plt.gca().set_aspect('equal', adjustable='box')\n",
    "plt.xlim(-5, 5)  # 设置 x 轴范围\n",
    "plt.ylim(-5, 5)  # 设置 y 轴范围\n",
    "plt.axhline(0, color='black', linewidth=0.5)\n",
    "plt.axvline(0, color='black', linewidth=0.5)\n",
    "plt.xticks(np.arange(-5,6))\n",
    "plt.yticks(np.arange(-5,6))\n",
    "plt.grid(color='gray', alpha=0.8, linestyle='-', linewidth=0.25) \n",
    "plt.legend()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f142ecfa-951c-49d4-a716-c536c4d1105f",
   "metadata": {},
   "source": [
    "作者\t**生姜DrGinger**  \n",
    "脚本\t**生姜DrGinger**  \n",
    "视频\t**崔崔CuiCui**  \n",
    "开源资源\t[**GitHub**](https://github.com/Visualize-ML)  \n",
    "平台\t[**油管**](https://www.youtube.com/@DrGinger_Jiang)\t\t\n",
    "\t\t[**iris小课堂**](https://space.bilibili.com/3546865719052873)\t\t\n",
    "\t\t[**生姜DrGinger**](https://space.bilibili.com/513194466)  "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:base] *",
   "language": "python",
   "name": "conda-base-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
